package com.ly.mpayment.rest.system;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.core.Context;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.ly.mpayment.core.util.JsonUtils;
import com.ly.mpayment.core.util.MapUtil;
import com.ly.mpayment.core.util.ResultMessage;
import com.ly.mpayment.core.util.StringUtils;
import com.ly.mpayment.persist.service.debituplog.IDebitUpLogService;
import com.ly.mpayment.persist.service.user.IUserService;
import com.ly.mpayment.rest.AbsRest;

import net.sf.json.JSONObject;

@Component
@Path("system/debituplog/")
public class DebitUpLogRest extends AbsRest {

	@Autowired
	IDebitUpLogService debitService;

	@Autowired
	IUserService userService;

	@POST
	@Path("findPageDebitLog")
	public String findPageDebitLog(String data,@Context HttpServletRequest request){
		String result = this.validationParameterGetRole(request,userService);
		if(result == null){
			JSONObject json = JsonUtils.converToJson(data);
			Map<String, Object> parameters = MapUtil.getMap();
				if(!StringUtils.isBlank(json.getString("useruuid"))){
					parameters.put(":useruuid", json.getString("useruuid"));
				}
				if(!StringUtils.isBlank(json.getString("starttime"))){
					parameters.put("starttime", json.getString("starttime"));
				}
				if(!StringUtils.isBlank(json.getString("endtime"))){
					parameters.put("endtime", json.getString("endtime"));
				}
				if(!StringUtils.isBlank(json.getString("phoneNum"))){
					parameters.put(":phoneNum", json.getString("phoneNum"));
				}

			return ResultMessage.getSucceed( JsonUtils.excludes(debitService.findPageDebitLog(parameters, json.getInt("start"),
					json.getInt("pageSize")), new String[]{"upshopuuid","provincialInformation","phonenum","password","userstatus",
					"usertype","token","lastlogintime","lastlogintime","errorCodesForUseruuid","expire","upshopip",
					"upkey","shopnum","status","upshopbalance","appId","orderStatusAddress","queryBalanceAddress","orderCommitAddress",
					"modifytime","uporderuuid","information","downRechargeFlow","upShopPro","userOrder","operators","statusremark",
					"upOrderId","upendtime","rechargeamount","discount","uprechargenum","childOrder","upendtimesec","callBack",
					"downShopName","sendStatus","discountAmount","upOrderRefunds","upOrderLogs","upOrderLogs","upOrderRefunds",
					"userOrder","upShopPro","downRechargeFlow","information","","downOrderRefunds","","","","","","","","","","","","","","","","","","","","",""}));
		}
		return result;
	}

}
